Skip to content

feat: post draft support with persisted store, autosave, and context-aware resumption#25

Draft
Copilot wants to merge 3 commits into
feat/draftsfrom
copilot/add-post-draft-support
Draft

feat: post draft support with persisted store, autosave, and context-aware resumption#25
Copilot wants to merge 3 commits into
feat/draftsfrom
copilot/add-post-draft-support

Conversation

Copilot AI commented Mar 31, 2026

Copy link
Copy Markdown

Replaces the single shared non-persisted composer state with a persisted draft system. Drafts are keyed by UUID, autosaved on debounced input, deleted on publish, and opened in a context-aware modal when the draft's parent post/group doesn't match the current composer location.

New modules

  • types/draft.tsPostDraft type capturing all composer state. DraftAttachment omits the non-serializable File field from NewAttachment. Includes toDraftAttachment/toNewAttachment converters.
  • store/persisted/useDraftStore.tscreatePersistedTrackedStore holding Record<string, PostDraft> with saveDraft/removeDraft actions.
  • store/non-persisted/modal/useDraftModalStore.ts — Controls the draft context-mismatch modal.
  • components/Composer/DraftList.tsx — Renders saved drafts sorted by updatedAt, with delete and context-aware open (matching context → main modal, mismatch → dedicated draft modal).

Modified modules

  • NewPublication — Generates a draft UUID on mount (draftId prop or new UUID). Autosaves via debounced useEffect (1s text, 2s attachments/audio/poll). Calls removeDraft in onCompleted.
  • NewPost — Renders <DraftList> below the composer trigger.
  • GlobalModals — Adds draft modal with DraftModalContent that hydrates all post stores from the draft via useEffect, then renders NewPublication with the draft's group/parent context.
  • data/storage.ts — Adds DraftStore key.

Draft state captured

Post content, attachments (sans File), audio metadata (artist, title, cover), video thumbnail/duration, quoted post, parent post, group, content warning, poll config, collect action, license, and post rules.

Copilot AI linked an issue Mar 31, 2026 that may be closed by this pull request
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 31, 2026

Copy link
Copy Markdown

Deploying palus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 33c4e55
Status: ✅  Deploy successful!
Preview URL: https://50a76e8c.palus.pages.dev
Branch Preview URL: https://copilot-add-post-draft-suppo.palus.pages.dev

View logs

Copilot AI changed the title [WIP] Add support for post drafts with persisted store feat: post draft support with persisted store, autosave, and context-aware resumption Mar 31, 2026
Copilot AI requested a review from iPaulPro March 31, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post draft support

2 participants